home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cocktail / mpp.lha / mpp / src / mpp.ell < prev    next >
Text File  |  1992-08-18  |  3KB  |  140 lines

  1. (* $Id: mpp.ell,v 1.6 1992/01/30 14:27:32 grosch rel $ *)
  2.  
  3. EXPORT {
  4. FROM Strings    IMPORT    tString;
  5.  
  6. TYPE tParsAttribute = tString;
  7. }
  8.  
  9. GLOBAL    {
  10. FROM StdIO    IMPORT    WriteC;
  11. FROM Scanner    IMPORT    BeginScanner, CloseScanner;
  12. FROM Strings    IMPORT    AssignEmpty, Append;
  13. FROM Table    IMPORT    BeginLine, CloseLine, NewLine, Define, Translate, WriteLine;
  14.  
  15. CONST cTab    = 11C;
  16. }
  17.  
  18. BEGIN    { BeginScanner; }
  19.  
  20. CLOSE    { CloseScanner; }
  21.  
  22. TOKEN
  23.   ' '
  24.   '^'
  25.   '%'
  26.   '$'
  27.   '.'
  28.   '\'
  29.   '{'
  30.   '}'
  31.   nl
  32.   bnl
  33.   char
  34.   tab
  35.  
  36. RULE
  37.  
  38. input:                /* the whole input */
  39.   line *
  40. .
  41.  
  42. line:                 /* one line */
  43.   '.' ( definition
  44.       | usage
  45.       )
  46. | normal
  47. .
  48.  
  49. definition:             /* definition */
  50.  
  51.   '.' bl ( char
  52.      | '^'            { char1.Ch := '^';        }
  53.      | '%'            { char1.Ch := '%';        }
  54.      | '$'            { char1.Ch := '$';        }
  55.      | '{'            { char1.Ch := '{';        }
  56.      | '}'            { char1.Ch := '}';        }
  57.      | '\'            { char1.Ch := '\';        }
  58.      ) bl            { AssignEmpty (text1);        }
  59.      [ text ] nl         { Define (char1.Ch, text1);    }
  60.                 { NewLine;            }
  61. .
  62.  
  63. usage:                /* usage */
  64.  
  65.   (                  { AssignEmpty (text1);        }
  66.     ( char
  67.     | '^'            { char1.Ch := '^';        }
  68.     | '%'            { char1.Ch := '%';        }
  69.     | '$'            { char1.Ch := '$';        }
  70.     | '{'            { char1.Ch := '{';        }
  71.     | '}'            { char1.Ch := '}';        }
  72.     ) [text] nl            { Translate (char1.Ch, text1);    }
  73.   |                { BeginLine;            }
  74.     bl use * ( nl        { CloseLine;            }
  75.       | bnl
  76.       )
  77.   )                { NewLine;            }
  78. .
  79.  
  80. normal:
  81.  
  82.   [ any             { WriteLine (any1);        }
  83.     ]
  84.     ( nl 
  85.     | bnl            { WriteC ('\');            }
  86.     )            { NewLine;            }
  87. .
  88.  
  89. bl:                /* skip blanks and tabs        */
  90.  
  91.   ( ' ' | tab ) *
  92. .
  93.  
  94. use:                /* usage            */
  95.  
  96.   '{' ( char
  97.       | '^'            { char1.Ch := '^';        }
  98.       | '%'            { char1.Ch := '%';        }
  99.       | '$'            { char1.Ch := '$';        }
  100.       | '{'            { char1.Ch := '{';        }
  101.       | '}'            { char1.Ch := '}';        }
  102.       | '\'            { char1.Ch := '\';        }
  103.       )             { AssignEmpty (text1);        }
  104.         bl [text] '}'        { Translate (char1.Ch, text1);    }
  105. | text                { Translate ('%', text1);    }
  106. .
  107.  
  108. text:                /* collect text            */
  109.                 { AssignEmpty (text0);        }
  110.   ( ' '                { Append (text0, ' ');        }
  111.   | '^'                { Append (text0, '^');        }
  112.   | '%'                { Append (text0, '%');        }
  113.   | '$'                { Append (text0, '$');        }
  114.   | '.'                { Append (text0, '.');        }
  115.   | char            { Append (text0, char1.Ch);    }
  116.   | tab                { Append (text0, cTab);        }
  117.   | '\'              { Append (text0, '\');        }
  118.      ( '\'            { Append (text0, '\');        }
  119.      | '{'            { Append (text0, '{');        }
  120.      | '}'            { Append (text0, '}');        }
  121.      | ' '            { Append (text0, ' ');        }
  122.      | tab            { Append (text0, cTab);        }
  123.      )
  124.   ) +
  125. .
  126.  
  127. any:                { AssignEmpty (any0);        }
  128.   ( ' '                { Append (any0, ' ');        }
  129.   | '^'                { Append (any0, '^');        }
  130.   | '%'                { Append (any0, '%');        }
  131.   | '$'                { Append (any0, '$');        }
  132.   | '.'                { Append (any0, '.');        }
  133.   | '\'                { Append (any0, '\');        }
  134.   | '{'                { Append (any0, '{');        }
  135.   | '}'                { Append (any0, '}');        }
  136.   | char            { Append (any0, char1.Ch);    }
  137.   | tab                { Append (any0, cTab);        }
  138.   ) +
  139. .
  140.